home *** CD-ROM | disk | FTP | other *** search
/ Executor 2.0 / executorv2.0.iso / mac / demoware / Asymptote 1.1 Demo / Scripts / Demos / 8) Hyperbola / demo8
Encoding:
Text File  |  1994-11-01  |  1.5 KB  |  83 lines  |  [TEXT/DWat]

  1. % Plot a hyperbola with asymptotes
  2. % You can alter the a and b values for the parabola
  3. set a 1
  4. set b 1
  5.  
  6. % Find the focus
  7. set c a a * b b * + sqrt
  8. npts 100
  9. graphlimits -3 a * 3 a * -3 a * 3 a *
  10. graphunits inches
  11. graphframe 1 6 1 6
  12. fullscreen yes
  13. fontname times
  14. fontsize 10
  15.  
  16. % Calculate the Hyperbola in each quadrant
  17. % and plot as a blue line
  18. pensize 2
  19. pencolor blue
  20. xrange a xright
  21. rpn <x dup * a dup * / 1 - b dup * * sqrt >y
  22. plotline
  23. % Flip it about the x axis to draw the 
  24. % other half of the curve
  25. rpn <y -1 * >y
  26. plotline
  27.  
  28. xrange "a -1 *" xleft
  29. rpn <x dup * a dup * / 1 - b dup * * sqrt >y
  30. plotline
  31. rpn <y -1 * >y
  32. plotline
  33.  
  34. % Draw the asymptotes to the hyperbola
  35. cliptoframe false
  36. pencolor red
  37. pensize 1
  38. moveto xleft xleft b * a /
  39. drawto xright xright b * a /
  40. moveto xleft xleft b * a / -1 *
  41. drawto xright xright b * a / -1 *
  42. pensize 0.25
  43. pencolor black
  44.  
  45. % Draw some labels
  46. moveto xleft 0
  47. drawarrowto xright 0
  48. moveto 0 ybottom
  49. drawarrowto 0 ytop
  50.  
  51. cliptoframe false
  52. moveto 0 ytop 1.05 *
  53. drawlabel 8 \iy
  54. moveto xright 1.05 * 0
  55. drawlabel 6 \ix
  56.  
  57. % Draw some lines to show x = -1 and x = +a
  58. pencolor 50 50 50  % 50% gray
  59. pendash 2
  60. set n npts xright a / / int
  61. moveto c -1 * 0
  62. drawto x(n) y(n)
  63. drawto c 0
  64.  
  65. moveto x(n) y(n)
  66. drawlabel 4 \iP(\ix,\iy)  
  67. moveto c -1 * .05
  68. drawlabel 8 \iF\d1(-\ic,0)
  69. moveto c .05
  70. drawlabel 8 \iF\d2(\ic,0)
  71.  
  72. pendash solid
  73. moveto a -1 * ybottom
  74. drawto a -1 * ytop .9 *
  75. drawlabel 8 \ix = -\ia
  76.  
  77. moveto a ybottom
  78. drawto a ytop .9 *
  79. drawlabel 8 \ix = -\ia
  80.  
  81. close xrange
  82.  
  83.